package com.wang.mandkey.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.wang.mandkey.App;
import com.wang.mandkey.R;
import com.wang.mandkey.tool.Tool;
import com.wang.mandkey.utils.ProjectEnvironment;
import com.wang.mandkey.utils.SharePersistent;
import com.wang.mandkey.utils.StringUtils;

public class EUIActivity extends BaseActivity {

	private Button mButtonAgree, mButtonNegative;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		String keyeui=SharePersistent.getPerference(this,ProjectEnvironment.STRING_KEY_EUI );
		if(!StringUtils.isEmptyNull(keyeui) &&ProjectEnvironment.STRING_VALUE_EUI.equals(keyeui) ){
			Tool.startOtherActivity(this, MainActivity.class);
		}else{
			setUpView();
		}
		
	}

	@Override
	void setUpView() {
		setContentView(R.layout.eui);
		mButtonAgree = (Button) findViewById(R.id.buttonAgree);
		mButtonAgree.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				SharePersistent.savePerference(EUIActivity.this,
						ProjectEnvironment.STRING_KEY_EUI,
						ProjectEnvironment.STRING_VALUE_EUI);
				Tool.startOtherActivity(EUIActivity.this, MainActivity.class);
			}
		});
		mButtonNegative = (Button) findViewById(R.id.buttonNegative);
		mButtonNegative.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				App.exitApp(EUIActivity.this);
			}
		});
	}
	@Override
	protected void onResume() {
		
		super.onResume();
		String keyeui=SharePersistent.getPerference(this,ProjectEnvironment.STRING_KEY_EUI );
		if(!StringUtils.isEmptyNull(keyeui) &&ProjectEnvironment.STRING_VALUE_EUI.equals(keyeui) ){
			Tool.startOtherActivity(this, MainActivity.class);
		}else{
			setUpView();
		}
	}
}
